package LeetCode.LeetCode2;

import java.util.HashMap;

/**
 * @author lumin
 * @date 2022/05/19 17:25
 **/
public class Num01_01 {
    public boolean isUnique(String astr) {
        HashMap<Character,Integer> map = new HashMap<>();
        for (int i = 0; i < astr.length(); i++) {
            if(map.containsKey(astr.charAt(i))){
                map.remove(astr.charAt(i));
                int value = map.get(astr.charAt(i));
                map.put(astr.charAt(i),value++);
            }else{
                map.put(astr.charAt(i),1);
            }
        }
        for (int i = 0; i < astr.length(); i++) {
            if(map.get(astr.charAt(i)) != 1){
                return false;
            }
        }
        return true;
    }
}